#include<bits/stdc++.h>
using namespace std;
#define int long long

int num, ans[10005][15], tmp[15];

void dfs(int k, int tar) {
	if (tar < 0)
		return ;
	if (k == 10 && !tar) {
		num++;
		for (int i = 1; i <= 10; i++)
			ans[num][i] = tmp[i];
		return ;
	}
	for (int i = 1; i <= 3; i++) {
		tmp[k + 1] = i;
		dfs(k + 1, tar - i);
	}
}

signed main() {
	int n;
	cin >> n;
	if (n < 10 || n > 30)
		cout << "0";
	else {
		dfs(0, n);
		cout << num << endl;
		for (int i = 1; i <= num; i++) {
			for (int j = 1; j <= 10; j++)
				cout << ans[i][j] << " ";
			cout << endl;
		}
	}
	return 0;
}
